home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / Dots & Pixels / sources / soundchannel.cp < prev    next >
Text File  |  1995-09-29  |  1KB  |  66 lines

  1.  
  2. #include <Types.h>
  3. #include <Resources.h>
  4. #include <QuickDraw.h>
  5. #include <ToolUtils.h>
  6. #include <Sound.h>
  7.  
  8. #include "soundchannel.h"
  9.  
  10. soundchannel::soundchannel()
  11. {
  12.     OSErr result;
  13.     
  14.     thechannel = 0L;
  15.     result = SndNewChannel( &thechannel, squareWaveSynth, 0, 0L);
  16.     
  17.     if( result != noErr)
  18.     {
  19.         DebugStr( "\pSndNewChannel failed");
  20.     }
  21. }
  22.  
  23. soundchannel::~soundchannel()
  24. {
  25.     (void)SndDisposeChannel( thechannel, true);
  26. }
  27.  
  28. void soundchannel::playsound( const int resno) const
  29. {
  30.     playsound( (SndListHandle)Get1Resource( 'snd ', resno));
  31. }
  32.  
  33. void soundchannel::playsound( SndListHandle thesound) const
  34. {
  35.     //
  36.     // NB: we do not use our own sound channel here (it is linked
  37.     // to the square wave synthesizer and cannot play all sounds)
  38.     //
  39.     SndPlay( 0L, thesound, false);
  40. }
  41.  
  42. void soundchannel::setamplitude( unsigned char amp) const
  43. {
  44.     sendcommand( ampCmd, amp, 0);
  45. }
  46.  
  47. void soundchannel::sendcommand( short cmd, short param1, long param2) const
  48. {
  49.     SndCommand thecommand;
  50.     thecommand.cmd    = cmd;
  51.     thecommand.param1 = param1;
  52.     thecommand.param2 = param2;
  53.  
  54.     (void)SndDoCommand( thechannel, &thecommand, false);
  55. }
  56.  
  57. void soundchannel::sendImmediate( short cmd, short param1, long param2) const
  58. {
  59.     SndCommand thecommand;
  60.     thecommand.cmd    = cmd;
  61.     thecommand.param1 = param1;
  62.     thecommand.param2 = param2;
  63.  
  64.     (void)SndDoImmediate( thechannel, &thecommand);
  65. }
  66.